window.addEventListener('load', function () {
    var regTel = /^1[3|4|5|7|8]\d{9}$/;
    var regQQ = /^[1-9]\d{4,}$/;
    var regNc = /^[\u4e00-\u9fa5]{2,8}$/;
    var regMsg = /^\d{6}$/;
    var regPwd = /^[a-zA-Z0-9]{6,18}$/;
    var tel = document.querySelector('#tel');
    var qq = document.querySelector('#qq');
    var nc = document.querySelector('#nc');
    var msg = document.querySelector('#msg');
    var pwd = document.querySelector('#pwd');
    var surePwd = document.querySelector('#surepwd');
    regexp(tel, regTel);
    regexp(qq, regQQ);
    regexp(nc, regNc);
    regexp(msg, regMsg);
    regexp(pwd, regPwd);
    function regexp(ele, reg) {
        ele.addEventListener('blur', function () {
            if (reg.test(this.value)) {
                this.nextElementSibling.className = 'right';
                this.nextElementSibling.innerHTML = '<i class="success_icon"></i> 恭喜您输入正确';
            } else {
                this.nextElementSibling.className = 'wrong';
                this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 格式不正确，请重新输入';
            }
        })
    }

    surePwd.addEventListener('blur', function () {
        if (surePwd.value == pwd.value) {
            this.nextElementSibling.className = 'right';
                this.nextElementSibling.innerHTML = '<i class="success_icon"></i> 恭喜您输入正确';
        } else {
            this.nextElementSibling.className = 'wrong';
                this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 两次密码输入不一致，请重新输入';
        }
    })
    

})
